package com.yunduo.entity.vo;

import com.yunduo.entity.GoodType;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 泛型返回数据 树形
 * @param <T>
 */
@AllArgsConstructor
@Data
public class TreeData {
    String id;
    String label;
    List children;
    public TreeData(Object data){
        String dataName = data.getClass().getName();
        String goodTypeName = GoodType.class.getName();
        if(goodTypeName.equals(dataName)){
            GoodType goodType =((GoodType)data);
            this.id = goodType.getId();
            this.label = goodType.getType();
            this.children = new ArrayList<TreeData>();
        }
    }
}
